/*
 * Copyright (C) 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.tony.demo.ui.performance.xnyh.draw;

import android.os.Bundle;
import android.view.View;

import androidx.core.content.ContextCompat;

import com.tony.demo.R;
import com.tony.demo.mvp.presenter.impl.BasePresenter;
import com.tony.demo.ui.base.BaseActivity;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

/**
 * Displays a fragment that contains a ListView holding several Chat objects. Used in this lesson
 * to show a) how to reduce overdraws, and b) how to flatten needlessly nested hierarchies.
 */
public class ChatumLatinumActivity extends BaseActivity {

    private boolean isOptimize;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (savedInstanceState == null) {
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.activity_chatum_latinum_container, new ChatsFragment())
                    .commit();
        }

        if (!isOptimize) {
            //模拟布局过度绘制效果
            View view = findViewById(R.id.activity_chatum_latinum_container);
            view.setBackgroundColor(ContextCompat.getColor(this, R.color.white));
        }
    }

    @Override
    protected int getViewLayout() {
        return R.layout.activity_chatum_latinum;
    }

    @Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
    public void isOptimize(String isOptimize) {
        this.isOptimize = isOptimize.equals("true");
    }

    @Override
    protected BasePresenter createPresenter() {
        return null;
    }
}